#include "web/pch.h"
#include "web/TcpSocket.h"
#include "web/Buffer.h"
#include "web/wsa.h"


int main()
{

    WSA::Init();


    auto newSocket=std::make_shared<Web::TcpSocket>();

    Web::SockAddrIn sockaddr;
    sockaddr.SetFamilyHostPort(AF_INET, "127.0.0.1", 6666);


    if (newSocket->Connect(sockaddr))
    {
        std::cout << "Failed connect" << std::endl;
    }

    int index = 0;

    while (1)
    {
        Web::Buffer buf;
        buf.no = index++;

        int sendLen = newSocket->Send<Web::Buffer>(buf);
        std::cout << "Send Len " << sendLen << std::endl;
        std::this_thread::sleep_for(std::chrono::milliseconds(500));
    }


    WSA::Clean();
    return 0;
}
